summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt
index f6aa370f0..eb4f513d1 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SearchFragment.kt
@@ -61,13 +61,6 @@ class SearchFragment : Fragment() {
binding.searchText.setText(savedInstanceState.getString(SEARCH_TEXT))
}
- gamesViewModel.searchFocused.observe(viewLifecycleOwner) { searchFocused ->
- if (searchFocused) {
- focusSearch()
- gamesViewModel.setSearchFocused(false)
- }
- }
-
binding.gridGamesSearch.apply {
layoutManager = AutofitGridLayoutManager(
requireContext(),
@@ -87,13 +80,22 @@ class SearchFragment : Fragment() {
filterAndSearch()
}
- gamesViewModel.games.observe(viewLifecycleOwner) { filterAndSearch() }
- gamesViewModel.searchedGames.observe(viewLifecycleOwner) {
- (binding.gridGamesSearch.adapter as GameAdapter).submitList(it)
- if (it.isEmpty()) {
- binding.noResultsView.visibility = View.VISIBLE
- } else {
- binding.noResultsView.visibility = View.GONE
+ gamesViewModel.apply {
+ searchFocused.observe(viewLifecycleOwner) { searchFocused ->
+ if (searchFocused) {
+ focusSearch()
+ gamesViewModel.setSearchFocused(false)
+ }
+ }
+
+ games.observe(viewLifecycleOwner) { filterAndSearch() }
+ searchedGames.observe(viewLifecycleOwner) {
+ (binding.gridGamesSearch.adapter as GameAdapter).submitList(it)
+ if (it.isEmpty()) {
+ binding.noResultsView.visibility = View.VISIBLE
+ } else {
+ binding.noResultsView.visibility = View.GONE
+ }
}
}